package com.boang.web;

import com.boang.po.Student;
import com.boang.service.StudentServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

/*
  @author: 13813
  @date: 2024/7/12 15:58
*/
@WebServlet("/h04")
public class ServletDemo04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取用户要查询的学生ID
        int id = Integer.parseInt(req.getParameter("id"));
        //创建service对象
        StudentServiceImpl studentService = new StudentServiceImpl();
        //调用service类中根据学生ID查询学生的方法
        Student student = studentService.getStuById(id);
        System.out.println(student);
    }
}
